<?php

class Session {
	static private $_saveHandler = null;

	static private $_initialized = false;

	public static function __init($name = null) {
		if (self::$_initialized) {
			return;
		}

		self::$_initialized = true;

		if ($name) {

			$class_name = 'Session_Adapter_' . ucfirst($name);

			Agilet::loadClass($class_name);

			self::$_saveHandler = $saveHandler = new $class_name;

			session_set_save_handler(array(&$saveHandler, 'open'), array(&$saveHandler, 'close'), array(&$saveHandler, 'read'), array(&$saveHandler, 'write'), array(&$saveHandler, 'destroy'), array(&$saveHandler, 'gc'));
		}
		@session_start();
	}

}
